<?php

declare(strict_types=1);

namespace App\Request;

use Hyperf\Validation\Request\FormRequest;
use Hyperf\Validation\Rule;

class StoreMaterialRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        $id = $this->input('id');
        return [
            'title' =>  [
                'required',
                'string',
                Rule::unique('material')->whereNull('deleted_at')->ignore($id),
            ],
            'start_time' => 'required',
            'end_time' => 'required',
        ];
    }

    public function attributes(): array
    {
        return [
            'title' => '清单名称',
            'start_time' => '开始时间',
            'end_time' => '结束时间'
        ];
    }
}
